package com.wing.purchase.model.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 采购需求列表
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("pur_purchase_plan")
public class PurchasePlan extends BaseEntity<PurchasePlan> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {

        /**
         * 待确认
         */
        stayConfirm(0, "待确认"),
        /**
         * 待审核
         */
        stayAudit(1, "待审核"),
        /**
         * 审核成功
         */
        success(2, "审核成功"),
        /**
         * 审核拒绝
         */
        fail(3, "审核拒绝");

        private int code;
        private String desc;

        Status(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        public String getDesc() {
            return this.desc;
        }
    }

    public enum CheckStatus implements IEnum<Integer> {

        /**
         * 待核对
         */
        stayCheck(0, "待核对"),
        /**
         * 核对中
         */
        checking(1, "核对中"),
        /**
         * 已核对
         */
        hasCheck(2, "已核对");

        private int code;
        private String desc;

        CheckStatus(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        @Override
        public Integer getValue() {
            return this.code;
        }

        public String getDesc() {
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 申报部门
     */
    private Long departmentId;

    /**
     * 部门角色
     */
    private Long roleId;

    /**
     * 采购计划编号
     */
    private String planNo;

    /**
     * 审核人
     */
    private Long auditor;

    /**
     * 审核时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime auditTime;

    /**
     * 状态
     */
    private Status status;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 是否可用
     */
    private Integer hasDisable;

    /**
     * 审核原因
     */
    private String reason;

    /**
     * 紧急程度ID
     */
    private Long purchaseUrgencyId;

    /**
     * 是否生单
     */
    private Boolean hasGenerateOrder;

    /**
     * 核对状态
     */
    private CheckStatus checkStatus;

    /**
     * 核对状态描述
     */
    @TableField(exist = false)
    private String checkStatusDesc;

    public String getCheckStatusDesc() {
        return checkStatus == null ? null : checkStatus.getDesc();
    }

    /**
     * 确认人
     */
    private Long affirmant;

    /**
     * 采购计划详情集合
     */
    @TableField(exist = false)
    private List<PurchasePlanDetail> planInfoList = new ArrayList<>();


    /**
     * 采购类型
     */
    private Long purTypeId;

    /**
     * 计划到货时间
     */
    private LocalDateTime planOnTime;

    /**
     * 总金额
     */
    private BigDecimal totalMoney;

    /**
     * sku数量
     */
    private Integer skuQuantity;

}
